import { mapGetters } from 'vuex'
import { themeList, addCss, removeAllCss } from './book'
export const ebookMixin = {
  computed: {
    ...mapGetters([
      'fileName',
      'menuVisible',
      'settingVisible',
      'defaultFontSize',
      'currentBook',
      'settingFontPopup',
      'defaultFontFamily',
      'defaultTheme',
      'progress',
      'bookAvailable'
    ]),
    themeList() {
      return themeList(this)
    }
  },
  methods: {
    initGlobalStyle() {
      removeAllCss()
      switch (this.defaultTheme) {
        case 'Default':
          addCss('http://localhost:8050/theme/theme_default.css')
          break
        case 'Gold':
          addCss('http://localhost:8050/theme/theme_gold.css')
          break
        case 'Eye':
          addCss('http://localhost:8050/theme/theme_eye.css')
          break
        case 'Night':
          addCss('http://localhost:8050/theme/theme_night.css')
          break
      }
    }
  }
}
